import * as API from '../utils/api'

export const LOAD_MODULES_LIST = 'LOAD_MODULES_LIST'
export const UPDATE_MODULES_LIST = 'UPDATE_MODULES_LIST'
import {loadAnnouncementList} from './announcement'
import {loadDemandList} from './demand'
import {loadConsultingList} from './consulting'
import {loadRoadShowList} from './roadShow'
import {loadGroupList} from './group'
import {loadEnterpriseShowList} from './enterpriseShow'
import {loadServiceShowList} from './serviceShow'
import {loadInvestShowList} from './investShow'

export const loadModulesList = () => dispatch => (API.fetchModules().then(json => {
    dispatch(updateModulesList({
        ...json
    }))
    const {data} = json
    data.map(module => {
        switch (module.moduleId) {
            // case '131':
            //     dispatch(loadAnnouncementList({pageNum: 1}));
            //     break;
            // case '132':
            //     dispatch(loadDemandList({pageNum: 1}));
            //     break;
            // case '133':
            //     dispatch(loadConsultingList({pageNum: 1}));
            //     break;
            // case '134':
            //     dispatch(loadRoadShowList({pageNum: 1}));
            //     break;
            // case '135':
            //     dispatch(loadGroupList({pageNum: 1}));
            //     break;
            // case '136':
            //     dispatch(loadEnterpriseShowList({showType: 1, pageNum: 1}));
            //     break;
            // case '137':
            // dispatch(loadServiceShowList({showType:2}));
            // break;
            case '138':
            dispatch(loadInvestShowList({showType:3}));
            break;
            default:
            break;
        }
    })
}))

export const updateModulesList = list => ({type: UPDATE_MODULES_LIST, list})